package com.freeland.client2009.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.freeland.client2009.dao.ibatis.GameInfoDAO;
import com.freeland.client2009.dao.ibatis.model.GameInfo;
import com.freeland.client2009.service.GameInfoService;

@Service("gameInfoService")
@Transactional
public class GameInfoServiceImpl implements GameInfoService {

	@Autowired
	private GameInfoDAO gameInfoDao;
	
	@Transactional(readOnly=true,propagation=Propagation.NOT_SUPPORTED)
	public List<GameInfo> getGameInfoList(GameInfo gameInfo) {
		return gameInfoDao.selectByParameter(gameInfo);
	}
	
	@Transactional(readOnly=true,propagation=Propagation.NOT_SUPPORTED)
	public List<GameInfo> getPushedGameInfoList(String areaId,String netBarId,String userType) {
		if(netBarId==null || netBarId.length()==0){
			return gameInfoDao.selectPushedGameListByAreaId(areaId,userType);
		}else{
			return gameInfoDao.selectPushedGameListByNetBarId(netBarId);
		}
		
	}
	public List<GameInfo> getDeletedGameInfoList(String areaId, String netBarId,String userType) {
		if(netBarId==null || netBarId.length()==0){
			return gameInfoDao.selectDeletedGameListByAreaId(areaId,userType);
		}else{
			return gameInfoDao.selectDeletedGameListByNetBarId(netBarId);
		}
	}
	public int updateGameInfo(GameInfo gameInfo) {
		gameInfoDao.updateByPrimaryKey(gameInfo);
		return gameInfo==null?0:1;
	}

	

}
